﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Globalization;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class RC_CatalogDtls : System.Web.UI.Page
    {
        private SsMng ssMng = new SsMng();
        private RecruitCatalogBLL catBLL = new RecruitCatalogBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDataGrid();
            }
        }
        private void LoadDataGrid()
        {
            Nullable<int> CatalogSeq = string.IsNullOrEmpty(Request.QueryString["ParentSeq"]) ? (int?)null : Int32.Parse(Request.QueryString["ParentSeq"]);

            try
            {
                DataSet ds = catBLL.LoadCatalogDtls((int?)null, CatalogSeq, (int?)null);
                DataTable dt = null;

                if (ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0];

                    RadGrid2.DataSource = dt;
                    RadGrid2.DataBind();
                }
            }
            catch (Exception ex)
            {

            }
        }

        protected void RadGrid2_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                int Sequence = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cat_dtls_seq"]);
                catBLL.DeleteDtls(Sequence, ssMng.EmpSeqI);
            }

            LoadDataGrid();
        }
    }
}
